const connection = require("../app/database");
class CommentLikeService {
  async create(moment_id, user_id, comment_id) {
    const statement = `INSERT INTO momment_comment_like (moment_id,user_id,comment_id) VALUES (?,?,?);`;
    const [result] = await connection.execute(statement, [
      moment_id,
      user_id,
      comment_id,
    ]);
    return result;
  }

  async loveCreate(moment_id, user_id) {
    const statement = `UPDATE moment_comment_like SET like_num =like_num+1 WHERE comment_id=?;`;
    const [result] = await connection.execute(statement, [moment_id]);
    return result;
  }

  async hateCreate(moment_id, user_id) {
    const statement = `UPDATE moment_comment_like SET no_like_num =no_like_num+1 WHERE comment_id=?;`;
    const [result] = await connection.execute(statement, [moment_id]);
    return result;
  }
}

module.exports = new CommentLikeService();
